<%@ page contentType="text/html;charset=UTF-8"%>
<!DOCTYPE html>
<html lang="en">

<head>

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">

<title>百虑</title>

<!-- Bootstrap Core CSS -->
<link href="../bower_components/bootstrap/dist/css/bootstrap.min.css"
	rel="stylesheet">

<!-- MetisMenu CSS -->
<link href="../bower_components/metisMenu/dist/metisMenu.min.css"
	rel="stylesheet">

<!-- Custom CSS -->
<link href="../dist/css/sb-admin-2.css" rel="stylesheet">

<!-- Custom Fonts -->
<link href="../bower_components/font-awesome/css/font-awesome.min.css"
	rel="stylesheet" type="text/css">

<link href="../dist/css/bootstrap3/bootstrap-switch.css"
	rel="stylesheet">

<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>

<body>

	<div id="wrapper">

		<!-- Navigation -->
		<nav class="navbar navbar-default navbar-static-top" role="navigation"
			style="margin-bottom: 0">
			<div class="navbar-header">
				<button type="button" class="navbar-toggle" data-toggle="collapse"
					data-target=".navbar-collapse">
					<span class="sr-only">test</span> <span class="icon-bar"></span> <span
						class="icon-bar"></span> <span class="icon-bar"></span>
				</button>
				<a class="navbar-brand" href="../index.jsp">百虑</a>
			</div>
			<!-- /.navbar-header -->

			<ul class="nav navbar-top-links navbar-right">
				<!-- /.dropdown -->
				<li class="dropdown"><a class="dropdown-toggle"
					data-toggle="dropdown" href="#"> <i class="fa fa-bell fa-fw"></i>
						<i class="fa fa-caret-down"></i> </a>
					<ul class="dropdown-menu dropdown-alerts">
						<li><a href="#">
								<div>
									<i class="fa fa-comment fa-fw"></i>温度过高 <span
										class="pull-right text-muted small">4分钟前</span>
								</div> </a>
						</li>
						<li class="divider"></li>

						<li><a class="text-center" href="#"> <strong>查看所有消息</strong>
								<i class="fa fa-angle-right"></i> </a>
						</li>
					</ul> <!-- /.dropdown-alerts -->
				</li>
				<!-- /.dropdown -->
				<li class="dropdown"><a class="dropdown-toggle"
					data-toggle="dropdown" href="#"> <i class="fa fa-user fa-fw"></i>
						<i class="fa fa-caret-down"></i> </a>
					<ul class="dropdown-menu dropdown-user">
						<li><a href="#"><i class="fa fa-user fa-fw"></i>陈俊毅</a>
						</li>
						<li><a href="#"><i class="fa fa-gear fa-fw"></i>设置</a>
						</li>
						<li class="divider"></li>
						<li><a href="../index.jsp"><i
								class="fa fa-sign-out fa-fw"></i> 注销</a>
						</li>
					</ul> <!-- /.dropdown-user -->
				</li>
				<!-- /.dropdown -->
			</ul>
			<!-- /.navbar-top-links -->

			<div class="navbar-default sidebar" role="navigation">
				<div class="sidebar-nav navbar-collapse">
					<ul class="nav" id="side-menu">
						<li><a href="./moritor.jsp"><i
								class="fa fa-dashboard fa-fw"></i> 主页</a>
						</li>
						<li><a href="#"><i class="fa  fa-steam fa-fw"></i> 控制</a>
						</li>
						<li><a href="./model.jsp"><i class="fa fa-gears fa-fw"></i>
								情景模式</a>
						</li>
					</ul>
				</div>
				<!-- /.sidebar-collapse -->
			</div>
			<!-- /.navbar-static-side -->
		</nav>

		<%
			if (request.getAttribute("hospitalEntitys") == null) {
		%><jsp:forward page="../getCommand"></jsp:forward>
		<%
			}
		%>

		<div id="page-wrapper">
			<div class="row">
				<div class="col-lg-12">
					<h1 class="page-header">控制</h1>
				</div>
				<div class="col-lg-4">
					<div class="panel panel-default">
						<div class="panel-heading">大灯</div>
						<div class="panel-body" align="center">
							<input class="form-control" type="checkbox" name="bulb" 
							<%
									if ((Integer) request.getAttribute("light") == 1) 
										out.print("checked");
							%>
							>
						</div>
					</div>
				</div>
				<div class="col-lg-6">
					<div class="panel panel-default">
						<div class="panel-heading">排插</div>
						<div class="panel-body">
							<div class="col-lg-3">
								插位1<input class="form-control" type="checkbox" name="socket1"
								<%
									if ((Integer) request.getAttribute("switch1") == 1) 
										out.print("checked");
							%>
								>
							</div>
							<div class="col-lg-3">
								插位2<input class="form-control" type="checkbox" name="socket2"
								<%
									if ((Integer) request.getAttribute("switch2") == 1) 
										out.print("checked");
								%>
								>
							</div>
							<div class="col-lg-3">
								插位3<input class="form-control" type="checkbox" name="socket3"
								<%
									if ((Integer) request.getAttribute("switch3") == 1) 
										out.print("checked");
								%>
								>
							</div>
						</div>
					</div>
				</div>
				<div class="col-lg-4">
					<div class="panel panel-default">
						<div class="panel-heading">窗户</div>
						<div class="panel-body" align="center">
							<input class="form-control" type="checkbox" name="window"
							<%
									if ((Integer) request.getAttribute("window") == 1) 
										out.print("checked");
							%>
							>
						</div>
					</div>
				</div>
				<div class="col-lg-4">
					<div class="panel panel-default">
						<div class="panel-heading">窗帘</div>
						<div class="panel-body" align="center">
							<input class="form-control" type="checkbox" name="curtain"
							<%
									if ((Integer) request.getAttribute("curtain") == 1) 
										out.print("checked");
							%>
							>
						</div>
					</div>
				</div>
				<div class="col-lg-4">
					<div class="panel panel-default">
						<div class="panel-heading">门</div>
						<div class="panel-body" align="center">
							<input class="form-control" type="checkbox" name="door"
							<%
									if ((Integer) request.getAttribute("door") == 1) 
										out.print("checked");
							%>
							>
						</div>
					</div>
				</div>
				<div class="col-lg-4">
					<div class="panel panel-default">
						<div class="panel-heading">空调</div>
						<div class="panel-body" align="center">
							<input class="form-control" type="checkbox" name="airCondition" onClick="click('airCon')"
							<%
									if ((Integer) request.getAttribute("airCondition") == 1) 
										out.print("checked");
							%>
							>
						</div>
					</div>
				</div>

			</div>
		</div>
	</div>
	<script src="../docs/js/jquery.min.js"></script>
	<script src="../dist/js/bootstrap-switch.js"></script>
	<!-- /#wrapper -->
	<script src="../js/command.js"></script>
	<script src="../bower_components/bootstrap/dist/js/bootstrap.min.js"></script>

	<!-- Metis Menu Plugin JavaScript -->
	<script src="../bower_components/metisMenu/dist/metisMenu.min.js"></script>

	<!-- Custom Theme JavaScript -->
	<script src="../dist/js/sb-admin-2.js"></script>
	<script src="../js/ajax.js"></script>

	<script>
		$(document).ready(function() {
			
			$('[type="checkbox"]').bootstrapSwitch();
		});
		
		
		$("[name='bulb']").on('switchChange.bootstrapSwitch',
				function(event, state) {
					send_State("light", state ? 1 : 0);
					post_Action("light",state);
				});

		$("[name='socket1']").on('switchChange.bootstrapSwitch',
				function(event, state) {
					send_State("switch1", state ? 1 : 0);
					post_Action("switch1",state);
				});

		$("[name='socket2']").on('switchChange.bootstrapSwitch',
				function(event, state) {
					send_State("switch2", state ? 1 : 0);
					post_Action("switch2",state);
				});

		$("[name='socket3']").on('switchChange.bootstrapSwitch',
				function(event, state) {
					send_State("switch3", state ? 1 : 0);
					post_Action("switch3",state);
				});

		$("[name='window']").on('switchChange.bootstrapSwitch',
				function(event, state) {
					send_State("window", state ? 1 : 0);
					post_Action("window",state);
				});

		$("[name='curtain']").on('switchChange.bootstrapSwitch',
				function(event, state) {
					send_State("curtain", state ? 1 : 0);
					post_Action("curtain",state);
				});

		$("[name='door']").on('switchChange.bootstrapSwitch',
				function(event, state) {
					send_State("door", state ? 1 : 0);
					post_Action("door",state);
				});

		$("[name='airCondition']").on('switchChange.bootstrapSwitch',
				function(event, state) {
					send_State("airCondition", state ? 1 : 0);
					post_Action("airCondition",state);
				});

		
	</script>


</body>

</html>
